package com.jron.cqiu.kernel.regist;

import static jnacontrib.win32.Registry.REGISTRY_ROOT_KEY.LOCAL_MACHINE;

import java.util.TreeMap;

/**
 * Created by Intellij IDEA.
 *
 * @Author: Yejw
 * @Date: 2008-6-16
 * @Time: 15:45:55
 */
public class Autorun implements IAutorun {

    /**
     * 检查自启动项是否存在
     *
     * @param name
     * @return
     */
    public boolean isExist(String name) {
        return IRegist.INSTANCE.valueExists(LOCAL_MACHINE, AUTORUN_KEY, name);
    }

    /**
     * 增加自启动项
     *
     * @param name
     * @param value
     * @return
     */
    public boolean add(String name, String value) {
        return IRegist.INSTANCE.setStringValue(LOCAL_MACHINE, AUTORUN_KEY, name, value);
    }

    /**
     * 移除自启动项
     *
     * @param name
     * @return
     */
    public boolean del(String name) {
        return IRegist.INSTANCE.deleteValue(LOCAL_MACHINE, AUTORUN_KEY, name);
    }

    /**
     * 修改自启动项
     *
     * @param name
     * @param value
     * @return
     */
    public boolean modfiy(String name, String value) {
        return IRegist.INSTANCE.setStringValue(LOCAL_MACHINE, AUTORUN_KEY, name, value);
    }

    /**
     * 获取自启动项
     *
     * @param name
     * @return
     */
    public String view(String name) {
        return IRegist.INSTANCE.getStringValue(LOCAL_MACHINE, AUTORUN_KEY, name);
    }

    /**
     * 获取全部自启动项
     *
     * @return
     */
    public TreeMap<String, Object> viewAll() {
        return IRegist.INSTANCE.getValues(LOCAL_MACHINE, AUTORUN_KEY);
    }
}
